<%@page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市订单管理系统</title>
    <link rel="stylesheet" href="/css/style.css"/>
    <link rel="stylesheet" href="/css/public.css"/>
</head>
<body>
<!--主体内容-->
	   <div class="location">
	       <strong>你现在所在的位置是:</strong> <span>供应商管理页面</span>
	   </div>
	   
	   	<div class="${updateClass }">${updateMsg }</div>
		<c:remove var="updateMsg" scope="session"/>
		<c:remove var="updateClass" scope="session"/>
		
        <div class="search">
            <form id="form2">
                <input name="method" value="query" type="hidden">
                <span>供应商编码：</span>
                <input name="idName" type="text" value="${providerQueryInfo.idName }">

                <span>供应商名称：</span>
                <input name="providerName" type="text" value="${providerQueryInfo.providerName }">

                <input value="查 询" type="button" id="searchbutton">
                <a href="javascript:toJump('/page/provider/providerAdd.jsp', '', '#mainframe')">添加供应商</a>
            </form>
        </div>
        <!--供应商操作表格-->
        <table class="providerTable" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="10%">供应商编码</th>
                <th width="20%">供应商名称</th>
                <th width="10%">联系人</th>
                <th width="10%">联系电话</th>
                <th width="10%">传真</th>
                <th width="10%">创建时间</th>
                <th width="30%">操作</th>
            </tr>
			
		<c:forEach items="${paProvider.items }" var="t">
		<tr>
			<td><span>${t.idName }</span></td>
			<td><span>${t.providerName }</span></td>
			<td><span>${t.phoneName }</span></td>
			<td><span>${t.phone }</span></td>
			<td><span>${t.fax }</span></td>
			<td><span>${t.date() }</span></td>
			<td><span> 
					<a class="viewProvider"
					   href="javascript:toJump('/provider/unique', 'id=${t.id }&page=providerDetail.jsp', '#mainframe')">
						<img src="/images/read.png" alt="查看" title="查看"/>
					</a>
				</span>
				<span> 
					<a class="modifyProvider"
					   href="javascript:toJump('/provider/unique', 'id=${t.id }&page=providerUpdate.jsp', '#mainframe')">
						<img src="/images/xiugai.png" alt="修改" title="修改" />
					</a>
				</span>
				<span> 
					<a class="deleteProvider" onclick="return confirm('确定删除供货商编码为${t.idName}的  ${t.providerName }吗?') "
					href="javascript:toJump('/provider/remove','id=${t.id }&curr=${paProvider.curr}', '#mainframe')">
						<img src="/images/schu.png" alt="删除" title="删除" />
					</a>
				</span>
			</td>
		</tr>
		</c:forEach>
        </table>
    <input type="hidden" id="totalPageCount" value="3" />
	<div class="page-bar">
		<ul class="page-num-ul clearfix">
			<li>共${paProvider.count }条记录&nbsp;&nbsp; ${paProvider.curr }/${paProvider.total }页</li>
			&nbsp;&nbsp;

			<a href="javascript:void(0)">首页</a>
			<a href="javascript:void(0)">上一页</a>
			<a href="javascript:void(0)">下一页</a>
			<a href="javascript:void(0)">尾页</a> &nbsp;&nbsp;
		</ul>
		<span class="page-go-form"><label>跳转至</label> <input
			type="text" name="inputPage" id="inputPage" class="page-key" />页
			<button type="button" class="page-btn"
				onClick='jump_to(document.forms[0],document.getElementById("inputPage").value)'>GO</button>
		</span>
	</div>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeProv">
    <div class="removerChid">
        <h2>提示</h2>

        <div class="removeMain">
            <p>你确定要删除该供应商吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>


<footer class="footer">
    版权归北大青鸟
</footer>
</body>

<!-- 保存当前页的后台路径和参数 -->
<c:set var="urlLoading" value="/provider/query" scope="session"></c:set>
<c:set var="paramLoading" value="curr=${paProvider.curr }" scope="session"></c:set>

<script type="text/javascript">
/* 设置翻页的超连接是否显示 */
 var curr = "${paProvider.curr }";
 var total = "${paProvider.total }";
 var count = "${paProvider.count }";
//判断是否是第一页
if(curr == 1){
	$(".page-num-ul a:lt(2)").hide();
}
//判断是否是最后一页
if(curr == total || count == 0){
	$(".page-num-ul a:gt(1)").hide();
}
$(".page-num-ul a:eq(0)").bind("click", function() {
	toJump(
		"/provider/query",
		$("#form2").serialize() + "&curr=1", "#mainframe"
	);
});
$(".page-num-ul a:eq(1)").bind("click", function() {
	toJump(
		"/provider/query",
		$("#form2").serialize() + "&curr=${paProvider.curr-1}", "#mainframe"
	);
});
$(".page-num-ul a:eq(2)").bind("click", function() {
	toJump(
		"/provider/query",
		$("#form2").serialize() + "&curr=${paProvider.curr+1}", "#mainframe"
	);
});
$(".page-num-ul a:eq(3)").bind("click", function() {
	toJump(
		"/provider/query",
		$("#form2").serialize() + "&curr=${paProvider.total}", "#mainframe"
	);
});

$(".page-go-form .page-btn").bind("click", function() {
	//获取跳转目标页码
	var target = $(".page-go-form .page-key").val();
	//获取当前页
	var curr = "${paProvider.curr}";
	//获取总页数
	var total = "${paProvider.total}";
	
	//判断, target的值是否符合数值格式
	if(!/^\d+$/.test(target)) {
		$(".page-go-form .page-key").val(curr);
		return;
	}
	//判断, target是否在合理的范围内
	if(target == curr || target < 1 || target > total){
		$(".page-go-form .page-key").val(curr);
		return;
	}
	
	//跳转
	toJump(
		"/provider/query",
		$("#form2").serialize() + "&curr="+target, "#mainframe"
	);
});

//为查询按钮绑定事件
$("#searchbutton").bind("click", function() {
	toJump(
		"/provider/query",
		$("#form2").serialize(), "#mainframe"
	);
});
</script>
</html>
